package com.xzit.tmms.controller.user;


import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.xzit.tmms.bean.user.User;
import com.xzit.tmms.common.base.BaseController;
import com.xzit.tmms.common.exception.ServiceException;
import com.xzit.tmms.service.user.MyService;
/**
 * 
 * @ClassName: myController
 * @Description: TODO
 * @author ChongQin
 * @date 2016年7月2日 上午10:05:56
 */
@Controller
@RequestMapping("/my")
public class myController extends BaseController{
     
	@Resource
	private MyService myService;
	
	@RequestMapping("")
	public String index() {
		return "user/my-pwd";
	}
	@RequestMapping("/updateMyPwdSubmit")
	public String updateMyPwdSubmit(Model model, Integer userId,String password,String newPwd,
			String newPwdSubmit) throws ServiceException {
		User user=myService.getMyPwdById(userId);
		if(user.getPassword().equals(password)){
			if(newPwd.equals(newPwdSubmit)){
			user.setPassword(newPwd);
			myService.updateMyPwd(user);
			}
		}
		return "redirect:/my.action";
	}
	
}
